// UserManagementDto.java
// 用户管理DTO
package org.example.backend.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import org.example.backend.entity.User;

public class UserManagementDto {
    // Getters and Setters
    @Getter
    private Long id;

    @Getter
    @NotBlank(message = "用户名不能为空")
    private String username;

    @Getter
    private String email;
    @Getter
    private String phone;

    @Getter
    @NotNull(message = "角色不能为空")
    private User.Role role;

    private Integer status = 1;

    // 新增关联信息字段
    @Getter
    private String realName; // 学生姓名/教师姓名/企业名称

    public void setId(Long id) {
        this.id = id;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public void setRole(User.Role role) {
        this.role = role;
    }

    public Integer getStatus() {
        // 规范化status值：非0值统一设为1（启用），0值保持为0（禁用）
        return status != null && status != 0 ? 1 : 0;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    // 添加realName的setter方法
    public void setRealName(String realName) {
        this.realName = realName;
    }
}
